home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 2.0 KB | 90 lines | [TEXT/MPS ] |
- ; Copyright © 1984-1990 Apple Computer, Inc. All rights reserved.
-
- Blanks On
- String AsIs
- Case On
-
- Print Off
- Include 'Macros.a'
- Include 'Traps.a'
-
- LOAD 'ProgStrucMacs.d'
- LOAD 'FlowCtlMacs.d'
- Print On
-
-
- ;-------------------------------------------------------------------
- ; Procedure ConvertToMenu(cmnuHandle: Handle; menuID: integer; AddToTable: ProcPtr);
- ;-------------------------------------------------------------------
- Seg 'TRes'
- EXPORT PROCEDURE CONVERTTOMENU(cmnuHandle:L, menuID:W, AddToTable:L)
- BEGIN SAVE=d3-d7/a2-a4
-
- move.l cmnuHandle(FP),a0 ;a0 <- cmnuHandle
- move.l (a0),a1
- move.w (a1),d7 ;d0 <- menuNumber
- clr.l d6
- move.b 14(a1),d6 ;d6 <- length of menu title
- move.l a1,d2
- add.l #15,d6
- add.l d6,d2
- move.l d2,a3 ;a3 now pointing at first menu item
- _GetHandleSize
- _NewHandle ;a0 <- hMENU
- move.l a0,d4 ;save it
- move.l (a0),a1 ;a1 <- pMENU
- move.l a1,a4 ;save it
- move.l cmnuHandle(FP),a0
- move.l (a0),a0
- move.l d6,d0
- _BlockMove ;move menu header into MENU resource
- add.l d6,a4
- move.w #0,d5 ;init itemNumber
- bra.s endWhile
-
- whileMoreItems
- addq.w #1,d5 ;bump itemNumber
- add.l #5,d6
- move.l a3,a0
- move.l a4,a1
- move.l d6,d0
- _BlockMove ;move menu item data sans command number
- add.l d6,a4
- add.l a3,d6
- btst #0,d6 ;test low order bit
- beq.s aligned
- addq #1,d6 ;align to next word
- aligned
- move.l d6,a3
- move.w (a3)+,d0
- beq.s endWhile
- move.w d0,-(sp)
- move.w d7,-(sp)
- move.w d5,-(sp)
- move.l AddToTable(FP),a0
- jsr (a0) ;jsr to AddToTable
- endWhile
- clr.l d6
- move.b (a3),d6
- bne.s whileMoreItems
-
- move.b #0,(a4)+
- move.l a4,d0
- move.l d4,a0
- sub.l (a0),d0
- _SetHandleSize
- move.l d4,-(sp) ;push hMENU
- move.l #'MENU',-(sp)
- move.w menuID(FP),-(sp) ;push menuID
- pea NilStr
- _AddResource
- move.l cmnuHandle(FP),-(sp) ;push cmnuHandle
- _RmveResource
- move.l cmnuHandle(FP),a0
- _DisposHandle
-
- Return
- NilStr
- DC.W 0
- EndProc
- END